echo Load VS2012 command prompt environment
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"

echo Clear build output
rmdir /S /Q "..\BuildOutput"

echo Build
cd "..\Unread.App"
MSBuild Unread.App.csproj /t:rebuild /p:Configuration=Release /p:OutDir=..\BuildOutput\

echo Save package output path
cd "..\BuildOutput\Unread.App\AppPackages\Unread.App_1.0.0.0_AnyCPU_Test"
set PackageOutputDir=%CD%

echo Validate package
call "C:\Program Files (x86)\Windows Kits\8.0\App Certification Kit\appcert.exe" reset
call "C:\Program Files (x86)\Windows Kits\8.0\App Certification Kit\appcert.exe" test -apptype windowsstoreapp -AppxPackagePath %PackageOutputDir%\Unread.App_1.0.0.0_AnyCPU.appx -reportoutputpath %PackageOutputDir%\..\..\..\ValidationResults.xml

echo Display validation results
copy %appdata%\..\Local\Microsoft\AppCertKit\ValidationResults.htm %PackageOutputDir%\..\..\..\
%PackageOutputDir%\..\..\..\ValidationResults.htm

echo Script done
pause